package cn.ht.jywrwater.module.ht.dal.mysql.town;

import java.util.*;

import cn.ht.jywrwater.framework.common.pojo.PageResult;
import cn.ht.jywrwater.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ht.jywrwater.framework.mybatis.core.mapper.BaseMapperX;
import cn.ht.jywrwater.module.ht.dal.dataobject.town.TownDO;
import org.apache.ibatis.annotations.Mapper;
import cn.ht.jywrwater.module.ht.controller.admin.town.vo.*;

/**
 * 乡镇管理 Mapper
 *
 * @author hzx
 */
@Mapper
public interface TownMapper extends BaseMapperX<TownDO> {

    default PageResult<TownDO> selectPage(TownPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TownDO>()
                .eqIfPresent(TownDO::getTownCode, reqVO.getTownCode())
                .likeIfPresent(TownDO::getTownName, reqVO.getTownName())
                .eqIfPresent(TownDO::getAddress, reqVO.getAddress())
                .eqIfPresent(TownDO::getPersonCharge, reqVO.getPersonCharge())
                .eqIfPresent(TownDO::getCustomerTel, reqVO.getCustomerTel())
                .eqIfPresent(TownDO::getHouseholdPerson, reqVO.getHouseholdPerson())
                .eqIfPresent(TownDO::getArea, reqVO.getArea())
                .eqIfPresent(TownDO::getRemark, reqVO.getRemark())
                .orderByDesc(TownDO::getId));
    }

    default List<TownDO> selectList(TownExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TownDO>()
                .eqIfPresent(TownDO::getTownCode, reqVO.getTownCode())
                .likeIfPresent(TownDO::getTownName, reqVO.getTownName())
                .eqIfPresent(TownDO::getAddress, reqVO.getAddress())
                .eqIfPresent(TownDO::getPersonCharge, reqVO.getPersonCharge())
                .eqIfPresent(TownDO::getCustomerTel, reqVO.getCustomerTel())
                .eqIfPresent(TownDO::getHouseholdPerson, reqVO.getHouseholdPerson())
                .eqIfPresent(TownDO::getArea, reqVO.getArea())
                .eqIfPresent(TownDO::getRemark, reqVO.getRemark())
                .orderByDesc(TownDO::getId));
    }

}
